package com.eaoa.uc.busvehicle.bo;

import java.util.Date;

import com.eaoa.base.EABaseBusinessObject;
import com.eaoa.dao.bus.BusVehicleDAO;
import com.eaoa.vo.bus.BusVehicle;

public class BusVehicleModifyBO extends EABaseBusinessObject{
	
	private static BusVehicleDAO vehicleDAO = new BusVehicleDAO();
	private BusVehicle vo ;
	private Long vehicleno;
	
	public BusVehicleModifyBO(BusVehicle vo) {
		super();
		this.vo = vo;
	}

	protected void performBusinessLogic() {
		vehicleno = vo.getVehicleno();
		
		if(vehicleno==null){
			
			vo.setIslock("N");
			vo.setCreatorno(getEmployee().getAccountno());
			vo.setCreatorname(getEmployee().getName());
			vo.setCreatedate(new Date());
			
			vehicleno = vehicleDAO.save(vo);
		}else{
			BusVehicle po =  (BusVehicle)vehicleDAO.loadAndLock(vehicleno);
			
			po.setVehiclecode(vo.getVehiclecode());
			po.setDriver(vo.getDriver());
			po.setPhone(vo.getPhone());
			po.setSize(vo.getSize());
			po.setLoadweight(vo.getLoadweight());
			po.setQuote(vo.getQuote());
			po.setRemarks(vo.getRemarks());
			po.setBuyyear(vo.getBuyyear());
			vehicleDAO.update(po);
		}
		
		
	}
	
	public Long getVehicleno(){
		return vehicleno;
	}
}
